package itheima.d04;

import itheima.d04.exception.nianji;
import itheima.d04.exception.yichang;

import java.util.Scanner;

public class test {
    public static void main(String[] args) throws nianji {
        //模拟注册的业务
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username = sc.next();
       if(username.equals("admin")){
           System.out.println("用户名已存在");
           throw new yichang("亲用户名已存在，换一个试试吧！");


       }else {
           System.out.println("注册成功");
       }
       //教研年纪，年纪必须是（1~160）
        System.out.println("请输入年龄：");
        int age = sc.nextInt();
        CheckAge(age);
    }

    private static void CheckAge(int age) throws nianji {
        if(age < 1 || age > 160){
            System.out.println("年龄输入错误");
            throw new nianji("年龄输入错误");


        }else {
            System.out.println("年龄输入正确");
        }
    }
}
